package com.taotao.rest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.common.utils.ExceptionUtil;
import com.taotao.rest.service.ContentService;

@Controller
public class ContentController {
	@Autowired
	private ContentService contentService;

	/**
	 * 发布根据cid获取内容content的服务
	 * 
	 * @param cid
	 * @return
	 * @author: JSJ
	 */
	@ResponseBody
	@RequestMapping("/content/{cid}")
	public TaotaoResult getContentList(@PathVariable("cid") long cid) {
		try {
			TaotaoResult result = contentService.getContentList(cid);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return TaotaoResult.build(500, ExceptionUtil.getStackTrace(e));
		}
	}

	/**
	 * 发布同步redis缓存中content的服务
	 * 
	 * @param cid
	 * @return
	 * @author: JSJ
	 */
	@ResponseBody
	@RequestMapping("/sync/content/{cid}")
	public TaotaoResult syncContent(@PathVariable long cid) {
		try {
			TaotaoResult result = contentService.syncContent(cid);
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			return TaotaoResult.build(500, ExceptionUtil.getStackTrace(e));
		}
	}
}
